package top.yudoge.dogeeditorserverj.common.objects;

import lombok.Data;

@Data
public class Response <T> {

    /**
     * 状态码 0：正常
     */
    private Integer code;
    /**
     * 错误信息
     */
    private String message;
    /**
     * 数据
     */
    private T data;

    private Response(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> Response<T> ok(T data) {
        return new Response<T>(0, null, data);
    }

    public static <T> Response<T> fail(Integer code, String message) {
        return new Response<T>(code, message, null);
    }

    public static <T> Response<T> fail(String message) {
        return fail(99999, message);
    }

}
